<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="static/vant/index.css">
    <link rel="stylesheet" href="static/element/index.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title>Title</title>

    <style>
        .el-select .el-input .el-select__caret::before {
            /*content: "\e78f"*/
            content: "";
            background: url(./img/Check.ico) center center no-repeat;
            position: absolute;
            width: 50%;
            height: 50%;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }

        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }

        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 138px;
            height: 180px;
            line-height: 180px;
            text-align: center;
        }

        .avatar {
            width: 138px;
            height: 180px;
            display: block;
        }

        .fail .layui-layer-content {
            background-color: brown;
            color: #eee;
            width: 400px;
            height: 30px;
            text-align: center;
        }

        .succeed .layui-layer-content {
            background-color: #0061A8;
            color: #eee;
            width: 400px;
            height: 30px;
            text-align: center;
        }
    </style>
</head>
<body>
<article class="page-container" id="app">

    <table style="table-layout:fixed; width: 100%; word-break:break-all;" class="table table-border table-bordered table-bg table-hover table-sort table-responsive" id="tablelist">
        <tbody id="datalist">
        <tr class="text-c">
            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">人员帐号</td>
            <td style="font-size: 0.8rem;">
                <input type="text" class="input-text" style="border:0;" v-model="ryzh" autocomplete="off" readonly="readonly">
            </td>
            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">人员姓名</td>
            <td style="font-size: 0.8rem;">
                <input type="text" class="input-text" style="border:0;" v-model="ryxm" autocomplete="off" readonly="readonly">
            </td>
        </tr>

        <tr class="text-c">
            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">部门</td>
            <td style="font-size: 0.8rem;">
                <el-select v-model="bmvalue" placeholder="请选择" size="medium" style="width: 100%; border: 0" disabled>
                    <el-option-group v-for="group in options"
                                     :key="group.label"
                                     :label="group.label">
                        <el-option
                                v-for="item in group.options"
                                :key="item.bmvalue"
                                :label="item.bmlabel"
                                :value="item.bmvalue">
                        </el-option>
                    </el-option-group>
                </el-select>
            </td>

            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">人员类别</td>
            <td style="font-size: 0.8rem;">
                <el-select v-model="rylb" placeholder="请选择" disabled>
                    <el-option
                            v-for="item in tableRylb"
                            :key="item.VALUE01"
                            :label="item.VALUE02"
                            :value="item.VALUE01">
                    </el-option>
                </el-select>
            </td>
        </tr>
        <tr class="text-c">
            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">工号</td>
            <td style="font-size: 0.8rem;">
                <input type="text" class="input-text" v-model="gh" style="border:0;" autocomplete="off" readonly="readonly">
            </td>
            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">消费类别</td>
            <td style="font-size: 0.8rem;">
                <el-select v-model="xflb" placeholder="请选择" disabled>
                    <el-option
                            v-for="item in tableXflb"
                            :key="item.VALUE01"
                            :label="item.VALUE02"
                            :value="item.VALUE01">
                    </el-option>
                </el-select>
            </td>
        </tr>
        <tr class="text-c">
            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">身份证号</td>
            <td style="font-size: 0.8rem;">
                <label>
                    <input type="text" v-model="sfzh" class="input-text" style="border:0;" readonly="readonly">
                </label>
            </td>
            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">电话号码</td>
            <td style="font-size: 0.8rem;">
                <label>
                    <input type="text" v-model="dhhm" class="input-text" style="border:0;" readonly="readonly">
                </label>
            </td>
        </tr>
        <tr class="text-c">
            <td style="width: 100px; font-weight: bolder; font-size: 22px; background: #eee;">旧卡卡号</td>
            <td style="font-size: 0.8rem;">
                <div style="text-align: left">
                    <input type="text" v-model="oldkh" class="input-text" style="border:0; font-size: 22px" readonly="readonly">
                </div>
            </td>
            <td style="width: 100px; font-weight: bolder; font-size: 22px; background: #eee;">新卡号码</td>
            <td style="font-size: 0.8rem;">
                <div style="text-align: left">
                    <input type="text" v-model="hysex" class="input-text" style="border:0;font-size: 22px;">
                </div>
            </td>
        </tr>

        <tr class="text-c">
            <td style="width: 100px; font-weight: bolder; font-size: 0.8rem; background: #eee;">照片</td>
            <td style="font-size: 0.8rem;  width: 80%">
                <img v-if="base64" :src="base64" class="avatar" alt="" style="margin: 0 auto;">
            </td>

            <td colspan="2">
                <input type="text" class="input-text" style="border:0; width: 0">
            </td>
        </tr>
        </tbody>
    </table>
    <van-row style="margin-top: 25px;">
        <van-col span="6"></van-col>
        <van-col span="6"></van-col>
        <van-col span="6">
            <div style="text-align: right">
                <van-button type="primary" @click="fDo()" style="width: 80%" v-loading.fullscreen.lock="fullscreenLoading">{{btnText}}</van-button>
            </div>
        </van-col>
        <van-col span="6">
            <div style="text-align: right">
                <van-button type="info" @click="fExit()" style="width: 80%">返回</van-button>
            </div>
        </van-col>
    </van-row>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="static/axios.min.js"></script>
<script type="text/javascript" src="./static/vue"></script>
<script src="static/vant/vant.min.js"></script>
<script src="static/element/index.js"></script>
<script type="text/javascript">

    let vm = new Vue({
        el: '#app',
        data: {
            flag: false,
            ryzh: '',
            ryxm: '',
            dqzt: '',
            options: [],
            tableRylb: [],
            tableXflb: [],
            bmvalue: '',
            rylb: '',
            gh: '',
            xflb: '',
            sfzh: '',
            dhhm: '',
            hysex: '',
            ismen: '',
            base64: '',
            upbase64: '',
            btnText: '',
            lock: false,
            oldkh:'',
            fullscreenLoading:false
        },
        methods: {
            fDo() {
                if (this.hysex.length === 0) {
                    layer.msg('请正确读出新卡卡号!', {icon: 0, time: 2000});
                    return
                }

                if (!this.lock) {
                    this.lock=true
                    let ls_opid = "${sessionOpid}";
                    let self = this
                    let params = new URLSearchParams();
                    params.append('CMD', "ZW");
                    params.append('VALUE01', ls_opid);        //--帐号
                    params.append('VALUE02', this.hysex);        //--新卡号码
                    params.append('VALUE03', this.ryzh);

                    axios.post('/f_wscl/com2', params)
                        .then(function (res) {
                            let {db1} = res.data
                            if (db1[0].VALUE01 === 'ZZ01') {
                                layer.msg('<span style="font-size:24px; line-height: 30px">' + db1[0].VALUE02 + '</span>', {time: 2000, skin: 'fail'});
                            } else if (db1[0].VALUE01 === 'ZZ00') {
                                layer.msg('<span style="font-size:24px; line-height: 30px">补卡或换卡完毕!</span>', {time: 2000, skin: 'succeed'}, function () {
                                    let index = parent.layer.getFrameIndex(window.name);
                                    parent.fGetinfoEmp();
                                    parent.layer.close(index);
                                });
                            }
                        })
                        .catch(function (error) {
                            layer.msg('<span style="font-size:24px; line-height: 30px">网络异常错误!</span>', {time: 1500, skin: 'fail'});
                        })
                        .finally(function () {
                            self.lock = false
                        });
                }
            },

            fInit(o) {
                let zz = o.tableTree
                let bm = o.tableTree
                let all = []
                let suboption = {}
                let citys = [];
                for (let i = 0; i < zz.length; i++) {
                    citys = []
                    let zzTmp = zz[i]
                    if (zzTmp.VALUE03 === '1') {
                        let zzbh = zzTmp.VALUE04
                        for (let j = 0; j < bm.length; j++) {
                            let bmTmp = bm[j]
                            if (bmTmp.VALUE05 === zzbh) {
                                let city = {};
                                city.bmvalue = bmTmp.VALUE04
                                city.bmlabel = bmTmp.VALUE02
                                citys.push(city)
                            }
                        }
                        suboption = {}
                        suboption.label = zzTmp.VALUE01
                        suboption.options = citys
                        all.push(suboption)
                    }
                }
                this.options = all;

                this.tableRylb = o.tableRylb
                this.tableXflb = o.tableXflb

                let empobj = o.tableEmp
                this.ryzh = empobj.VALUE10.toString()
                this.ryxm = empobj.VALUE01.toString()
                this.gh = empobj.VALUE02.toString()
                this.bmvalue = empobj.VALUE11.toString()
                this.rylb = empobj.VALUE12.toString()
                this.xflb = empobj.VALUE13.toString()
                this.sfzh = empobj.VALUE07.toString()
                this.dhhm = empobj.VALUE08.toString()
                this.ismen = empobj.VALUE15.toString()      //--是否上传门禁系统
                this.dqzt = empobj.VALUE17.toString()   //--当前状态
                this.oldkh = empobj.VALUE19.toString()   //
                this.btnText = o.btnText

                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "BL");
                params.append('VALUE01', this.ryzh);
                this.fullscreenLoading=true
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        //--db1左边表结构的树  db2人员分类
                        let {db1} = res.data
                        self.base64 = db1[0].VALUE01.toString()     //--人脸信息
                        if (self.base64.indexOf("base64,") === -1) {
                            self.base64 = "data:image/jpg;base64," + self.base64;
                        }
                    })
                    .catch(function (error) {
                    }).finally(function () {
                    self.fullscreenLoading=false
                });
            },

            fExit() {
                let index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            }
        },

        created() {
            window.fInit = this.fInit
        }
    })

    $(document).ajaxComplete(function (event, xhr, settings) {
        //从http头信息取出 在filter定义的sessionstatus，判断是否是 timeout
        if (xhr.getResponseHeader("sessionstatus") === "timeout") {
            //从http头信息取出登录的url ＝ loginPath
            if (xhr.getResponseHeader("loginPath")) {
                window.location.replace(xhr.getResponseHeader("loginPath"));
            }
        }
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
